﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Console.aspx.cs" Inherits="Web.Console" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>在线API调用工具</title>
    <link rel="stylesheet" href="css/json-diff.css" type="text/css" media="screen" title="no title"></link>
</head>
<body>
    <h1><%=Session["ProjectName"] %></h1>
    <form id="form1" runat="server" >
    <div class="contentbox" align="right">
        <asp:Button ID="BtnExit" runat="server" Text="退出" onclick="BtnExit_Click" /></div>
    <div class="contentbox" id="Div1">
        <h4>SecretKey</h4><asp:TextBox ID="TxtSecretKey" runat="server"></asp:TextBox>
        <br />
        <h4>分类</h4><asp:DropDownList ID="DropDownListGroup" runat="server" DataSourceID="SqlDataSourceGroup"
            DataTextField="Name" DataValueField="ID" AutoPostBack="True">
            <asp:ListItem Value="0">未选择</asp:ListItem>
        </asp:DropDownList>
        <br />
        <h4>API</h4><asp:DropDownList ID="DropDownListAPI" runat="server" DataSourceID="SqlDataSourceAPI"
            DataTextField="Name" DataValueField="ID" AutoPostBack="True">
            <asp:ListItem Value="0">未选择</asp:ListItem>
        </asp:DropDownList>
        <br />
        <h4>获取方式</h4><asp:RadioButton ID="RadioButtonPost" runat="server" Text="Post" Checked="True"
            GroupName="Method" />
        <asp:RadioButton ID="RadioButtonGet" runat="server" Text="Get" GroupName="Method" />
        <br />
        <h4>API参数</h4>
        <asp:GridView ID="GridViewParameter" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
            DataSourceID="SqlDataSourceParameter">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                    SortExpression="ID" Visible="False"/>
                <asp:CheckBoxField DataField="Required" HeaderText="Required" 
                    SortExpression="Required" />
                <asp:BoundField DataField="Range" HeaderText="Range" SortExpression="Range" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                    
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:TemplateField>
                    <HeaderTemplate>Value</HeaderTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="TxtValue" Text='<%# Bind("Default") %>' runat="server"></asp:TextBox>
                    </ItemTemplate>   
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <br />
        <asp:Button ID="BtnRun" runat="server" Text="调用接口" OnClick="BtnRun_Click" />
        <br />
        
        
        <asp:SqlDataSource ID="SqlDataSourceGroup" runat="server" ConnectionString="<%$ ConnectionStrings:OnlineAPIConnectionString %>"
            SelectCommand="SELECT [ID], [Name] FROM [Group]">
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="SqlDataSourceAPI" runat="server" ConnectionString="<%$ ConnectionStrings:OnlineAPIConnectionString %>"
            SelectCommand="SELECT * FROM [API] WHERE ([GroupID] = @GroupID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownListGroup" Name="GroupID" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="SqlDataSourceParameter" runat="server" ConnectionString="<%$ ConnectionStrings:OnlineAPIConnectionString %>"
            
            SelectCommand="SELECT ID, ProjectID, APIID, Name, Required, Range, Description, [Default] FROM RequestParameter WHERE (ProjectID = @ProjectID) AND (APIID = @APIID OR APIID = 0)">
            <SelectParameters>
                <asp:SessionParameter Name="ProjectID" SessionField="ProjectID" />
                <asp:ControlParameter ControlID="DropDownListAPI" Name="APIID" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    <h2>Results
    </h2><asp:Button ID="BtnClear" runat="server" Text="Chear" 
        onclick="BtnClear_Click" />
        <div class="contentbox" runat="server" id="DivResult">
        </div>
    </form>
    
    
</body>
</html>
